<?PHP
	function linkTo($name,$path,$is_blank=false){
		$paths = explode("/",$path);
		$controller = array_shift($paths);
		$action = array_shift($paths);
		$params = join("/",$paths);
		$root = (application_use_human_url) ? application_path : application_path."index.php?path=";
		$use_blank = ($is_blank) ? " target=\"_blank\"" : "";
		$class_name = $controller."Controller";
		if(in_array($action,get_class_methods($class_name))){
			$temp_class = new $class_name();
			if($temp_class->__checkUserAcess($action)){
				return "<a href=\"$root$controller/$action/$params\"$use_blank>".((application_debug_enviroment)?"<img src=\"images/blue.gif\" width=\"10\" height=\"10\" border=\"0\"> ":"")."$name</a>";	
			}else{
				return "";
			}
		}else{
			return "<img src=\"images/orange.gif\" width=\"10\" height=\"10\" border=\"0\"> T_BAD_LINK_TO:$controller/$action/$params";
		}
	}
	function linkForm($path){
		$paths = explode("/",$path);
		$controller = array_shift($paths);
		$action = (count($paths)>0) ? array_shift($paths):"index";
		$params = join("/",$paths);
		$root = (application_use_human_url) ? application_path : application_path."index.php?path=";
		
		$class_name = $controller."Controller";
		if(in_array($action,get_class_methods($class_name))){
			return "$root$controller/$action/$params".((application_debug_enviroment)?"\" style=\"background-color:#FFFF99":"");	
		}else{
			return "$root$controller/$action/$params".((application_debug_enviroment)?"\" style=\"background-color:#FF0000":"");
		}
	}
	function linkRedirect($path,$time=0){
		$paths = explode("/",$path);
		$controller = array_shift($paths);
		$action = array_shift($paths);
		$params = join("/",$paths);
		$root = (application_use_human_url) ? application_path : application_path."index.php?path=";
		
		$class_name = $controller."Controller";
		if(in_array($action,get_class_methods($class_name))){
			/*return "<script language=\"javascript\">location.replace(\"$root$controller/$action/$params\");</script>";*/
			return "<meta http-equiv=\"refresh\" content=\"$time; URL=$root$controller/$action/$params\">";
		}else{
			return "T_BAD_LINK_TO:$controller/$action/$params";
		}
		
	}
	/**********************************************
	* Link to an absolute or relative path, no check is processed
	**********************************************/
	function linkUri($name,$path,$is_blank=false,$title=NULL){
		$use_blank = ($is_blank) ? " target=\"_blank\"" : "";
		if($title==NULL) $title = $name;
		$url = ((application_debug_enviroment)?"<img src=\"images/blue.gif\" width=\"10\" height=\"10\" border=\"0\"> ":"")."<a href=\"$path\" title=\"$title\"$use_blank>$name</a>";
		return $url;
	}
?>